<template>
  <div>
    <el-card>
      <div slot="header">
        <span>文章热度查询</span>
      </div>
      <div id="main" :style="{width: '100%', height: '500px'}"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts/core'
import { GaugeChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'

echarts.use([GaugeChart, CanvasRenderer])

export default {
  name: 'eCharts',
  data () {
    return {
      option: {
        series: [
          {
            type: 'gauge',
            axisLine: {
              lineStyle: {
                width: 30,
                color: [
                  [0.3, '#1fddff'],
                  [0.7, '#d3684b'],
                  [1, '#f12711']
                ]
              }
            },
            pointer: {
              itemStyle: {
                color: 'auto'
              }
            },
            axisTick: {
              distance: -30,
              length: 8,
              lineStyle: {
                color: '#fff',
                width: 2
              }
            },
            splitLine: {
              distance: -30,
              length: 30,
              lineStyle: {
                color: '#fff',
                width: 4
              }
            },
            axisLabel: {
              color: 'auto',
              distance: 40,
              fontSize: 20
            },
            detail: {
              valueAnimation: true,
              formatter: '{value} dot',
              color: 'auto'
            },
            data: [
              {
                value: 70
              }
            ]
          }
        ]
      }
    }
  },
  mounted () {
    this.drawLine()
  },
  methods: {
    drawLine () {
      var chartDom = document.getElementById('main')
      var myChart = echarts.init(chartDom)
      myChart.setOption(this.option)
    }
  }
}
</script>

<style lang="less" scoped></style>
